<template>
  <div>
    <el-form
      ref="searchForm"
      class="searchForm"
      :model="searchForm"
      label-width="50"
    >
      <el-row :gutter="12">
        <!--        合计24份  -->
        <el-col :span="6">
          <el-form-item prop="queryCondition.cmDescrSm" label="商品名称">
            <el-input v-model.trim="searchForm.queryCondition.cmDescrSm">
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item prop="queryCondition.commodityFk" label="商品编号">
            <el-input v-model="searchForm.queryCondition.commodityFk">
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item prop="queryCondition.actualStockMin" label="实际库存最小值">
            <el-input v-model="searchForm.queryCondition.actualStockMin">
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item prop="queryCondition.actualStockMax" label="实际库存最大值">
            <el-input v-model="searchForm.queryCondition.actualStockMax">
            </el-input>
          </el-form-item>
        </el-col>
      </el-row>

      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-edit"
          @click="queryByCondition(1)"
          >查询</el-button
        >
        <el-button
          type="warning"
          icon="el-icon-remove"
          @click="() => $refs.searchForm.resetFields()"
          >重置</el-button
        >
      </el-form-item>
    </el-form>
    <!--          {
      "storageId": 1,
      "commodityFk": "CC21843239000163",
      "cmDescr": "伊犁利乐包纯牛奶",
      "intentionStock": 0,
      "actualStock": 0,
      "soldStock": 0,
      "isDeleted": false,
      "version": 0
    },-->
    <el-table :data="results" class="resultsTable" stripe>
      <el-table-column prop="storageId" label="ID"></el-table-column>
      <el-table-column prop="commodityFk" label="Code"></el-table-column>
      <el-table-column prop="cmDescr" label="商品名称"></el-table-column>
      <el-table-column
        prop="intentionStock"
        label="意向采购库存"
      ></el-table-column>
      <el-table-column prop="actualStock" label="实际库存"></el-table-column>
      <el-table-column prop="soldStock" label="已售库存"></el-table-column>

      <!--                <el-table-column label="" :formatter="Format">-->
      <!--                </el-table-column>-->
      <el-table-column width="180px" fixed="left">
        <template slot-scope="props">
          <el-button
            class="el-button--mini"
            type="warning"
            icon="el-icon-edit"
            @click="openById(props.row.storageId)"
            >编辑</el-button
          >
          <el-button
            class="el-button--mini"
            type="danger"
            icon="el-icon-edit"
            @click="deleteById(props.row.storageId)"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      :total="total"
      :page-size="searchForm.pageSize"
      :current-page="searchForm.pageNum"
      @current-change="queryByCondition"
      layout="total, prev, pager, next, jumper"
    ></el-pagination>
  </div>
</template>

<script>
import { commodityModuleApi } from "@/api/apis";
// import New from './components/New.vue';
export default {
  name: "GoodsStorage",
  components: {
    // New,Old,
  },
  props: {
    sampleP: {
      type: Number,
      default: 0,
    },
  },
  data() {
    return {
      sampleD: "value",
      searchForm: {
        pageNum: 1,
        pageSize: 10,
        queryCondition: {
          actualStockMax: null,
          actualStockMin: null,
          cmDescrSm: null,
          commodityFk: null,
        },
      },
      total: 0,
      results: [],
    };
  },
  computed: {
    // sampleC() {
    //     return this.sampleD+'--';
    // }
  },
  created() {},
  mounted() {
    this.queryByCondition(1);
  },
  methods: {
    sampleM() {},
    queryByCondition(pageNum) {
      if (pageNum) this.searchForm.pageNum = pageNum;
      // this.$http({
      //   method: "post",
      //   url: "/storage/query",
      //   data: this.searchForm,
      // })
      commodityModuleApi.storageQueryApi(this.searchForm).then(
        (res) => {
          this.total = res.data.total;
          this.results = res.data.results;
        },
        (error) => {
          this.$message.warning("query mistake：" + error.response.status);
        }
      );
    },
  },
  watch: {
    // sampleC(newValue, oldValue) {
    //
    // }
  },
};
</script>

<!--<style scoped>-->
<style lang="scss" scoped></style>
